package appconfig

import (
	"fmt"

	"github.com/spf13/viper"
)

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type AppConfig struct {
	Mysql
}

var Conf AppConfig

func Init() {
	var err error
	viper.SetConfigFile("../appconfig/dev.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic("配置读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic("配置解析失败")
	}
	fmt.Println(Conf)
}
